/* 
 * Copyright 2008 Rodrigo Reyes <reyes.rr at gmail dot com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
**/
package net.kornr.abstractcanvassamples;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.google.gwt.widgetideas.graphics.client.Color;

import net.kornr.abstractcanvas.awt.Canvas;
import net.kornr.abstractcanvassamples.client.ColorTest;
import net.kornr.abstractcanvassamples.client.PathTest;

public class AWTDemo extends JPanel
{
	private static final long serialVersionUID = 1L;
	private Canvas m_canvas = new Canvas();

	public AWTDemo()
	{
		this.setLayout(new BorderLayout());
		this.add(BorderLayout.CENTER, m_canvas);
	}

	static public void main(String[] args) throws InterruptedException
	{
		AWTDemo jct = new AWTDemo();
		
		JFrame frame = new JFrame("Swing Demo");
		frame.getContentPane().setLayout(new BorderLayout());
		frame.getContentPane().add(jct, BorderLayout.CENTER);
		frame.setSize(320,180);
		frame.setVisible(true);

		ColorTest sample1 = new ColorTest();
		PathTest sample2 = new PathTest();

		// We can use directly the canvas without the controller
		// as long as we don't use text
		jct.m_canvas.setFillStyle(Color.WHITE);
		jct.m_canvas.setGlobalAlpha(1.0);
		jct.m_canvas.fillRect(0, 0, jct.m_canvas.getCoordWidth(), jct.m_canvas.getCoordHeight());
		
		jct.m_canvas.addCanvasPainter(sample1);
		jct.m_canvas.addCanvasPainter(sample2);
		jct.setSize(300,150);		
		frame.getContentPane().repaint();

	}

}
